<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>123</div>
    <a href="www.baidu.com">123</a>
    <script>
      //阻止默认a跳转行为
      var a = document.querySelector('a');
      a.onclick = function (e) {
        //1.e.preventDefault();
        
        console.log('hahaha');

        // 2.
        return false; //return不可以阻止 监听事件类型
      };
    </script>
  </body>
</html>
